﻿using System;
using GeoAPI.Geometries;
using YJKGridTopologyCal.Utilities;

namespace YJKGridTopologyCal.GeometriesGraph
{
	public abstract class GraphComponent
	{
		protected GraphComponent()
		{
		}

		protected GraphComponent(Label label)
		{
			this._label = label;
		}

		public Label Label
		{
			get
			{
				return this._label;
			}
			protected internal set
			{
				this._label = value;
			}
		}

		public bool InResult { get; set; }

		public bool IsInResult
		{
			get
			{
				return this.InResult;
			}
		}

		public bool Covered
		{
			get
			{
				return this._isCovered;
			}
			set
			{
				this._isCovered = value;
				this._isCoveredSet = true;
			}
		}

		public bool IsCovered
		{
			get
			{
				return this.Covered;
			}
		}

		public bool IsCoveredSet
		{
			get
			{
				return this._isCoveredSet;
			}
		}

		public bool Visited
		{
			get
			{
				return this._isVisited;
			}
			set
			{
				this._isVisited = value;
			}
		}

		public bool IsVisited
		{
			get
			{
				return this._isVisited;
			}
		}

		public abstract Coordinate Coordinate { get; protected set; }

		public abstract void ComputeIM(IntersectionMatrix im);

		public abstract bool IsIsolated { get; }

		public void UpdateIM(IntersectionMatrix im)
		{
			Assert.IsTrue(this._label.GeometryCount >= 2, "found partial label");
			this.ComputeIM(im);
		}

		private Label _label;

		private bool _isCovered;

		private bool _isCoveredSet;

		private bool _isVisited;
	}
}
